package com.misic.cofig;

import com.misic.utils.FileUploadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class FileConfig   implements WebMvcConfigurer {
    @Autowired
    private FileUploadProperties fileUploadProperties;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry
                .addResourceHandler(fileUploadProperties.getAccessPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getArtistphotoaddress());
        registry
                .addResourceHandler(fileUploadProperties.getSonglistpictureaddressPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getSonglistpictureaddress());
        registry
                .addResourceHandler(fileUploadProperties.getSongpictureaddressPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getSongpictureaddress());
        registry
                .addResourceHandler(fileUploadProperties.getSongaddressPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getSongaddress());
        registry
                .addResourceHandler(fileUploadProperties.getFrontenduseravataraddressPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getFrontenduseravataraddress());
        registry
                .addResourceHandler(fileUploadProperties.getUseravatardefaultaddressPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getUseravatardefaultaddress());
        registry
                .addResourceHandler(fileUploadProperties.getSwiperPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getSwiper());
        registry
                .addResourceHandler(fileUploadProperties.getSwiperPath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getSwiper());
        registry
                .addResourceHandler(fileUploadProperties.getSecnsePath() + "/**")
                .addResourceLocations("file:"+fileUploadProperties.getSecnse());
    }

}
